<?php

class Application_Model_WayWeight extends Application_Model_DomainObject{
    
    protected $_id;
    
    protected $_type;
    
    protected $_weight;
    
    protected $_wayId;
    
    private $_typeBy;
    
    public function getTypeBy(){
        if($this->_typeBy == NULL){
            $this->_typeBy = Application_Model_WeightType::load($this->_type);
        }
        return $this->_typeBy;
    }
    
    public static function getByWayId($billid)
    {
        return self::getDao()->queryAll(array("wayId"=>$billid));
    }
    
    public static function getWeightByType($id,$type)
    {
        $where[" wayId = "] = $id;
        $where[" and type = "] = $type;
        return self::getDao()->queryOne($where);
    }
    
    public static function getVweightByWayId($wayId){
        $where["wayId = "] = $wayId;
        $res = self::getDao()->queryAll($where, " weight desc");
        return $res[0]->weight;
    }
    
    public static function getSumWeightByTypeOperator($operateType,$operator,$type,$weightType,$startDate,$endDate)
    {        
        $wayWeightDb = new Application_Model_DbTable_WayWeight();
        return $wayWeightDb->getSumWeightByTypeOperator($operateType,$operator,$type,$weightType,$startDate,$endDate);
    }
    
}